<!--
  - Copyright (c) 2018.
  - 北京九思金信科技有限公司对该文件内容保留所有权利。
  - 未经许可，不得私自拷贝、传播、发布、引用该文件内容，违者将被追究法律责任。
  -->
<template>
  <div>
    <div class="sue_img" @click="sueSearch">
      <img src="@/assets/img/Search@3x.png" alt />
    </div>
    <div class="scroll">
      <scroll class="sue_box">
        <div class="sue_center_box">
          <div class="sue_center_box_child sue_center_sue">
            <h3>为你推荐</h3>
            <div>
              <div
                class="sue_center_sue_info"
                v-for="item in sueRecommendDataInfo"
                :key="item.id"
                @click="appItem(item.routeUrl)"
              >
                <img v-lazy="sueRecommendDataInfoImg(item.appImgId)" alt />
                <em>{{ item.appletName }}</em>
              </div>
            </div>
          </div>
          <div
            class="sue_center_box_child sue_center_sue"
            v-for="item in sueSortDataInfo"
            :key="item.id"
          >
            <h3>{{ item.categoryName }}</h3>
            <div>
              <div
                class="sue_center_sue_info"
                v-for="seif in item.appletVOS"
                :key="seif.id"
                @click="appItem(seif.routeUrl)"
              >
                <img
                  v-if="seif.appImgId"
                  v-lazy="sueRecommendDataInfoImg(seif.appImgId)"
                  alt
                />
                <em>{{ seif.appletName }}</em>
              </div>
            </div>
          </div>
        </div>
        <!-- loading 组件 -->
        <div v-show="!sueSortDataInfo.length" class="loading-container">
          <joys-loading></joys-loading>
        </div>
      </scroll>
    </div>
    <router-view></router-view>
  </div>
</template>

<script>
import Scroll from "@/components/JoysScroll/JoysScroll";
import JoysLoading from "@/components/JoysLoading/JoysLoading";
export default {
  name: "sue",
  components: {
    Scroll,
    JoysLoading
  },
  data () {
    return {
      sueRecommendDataInfo: [],
      sueSortDataInfo: []
    };
  },
  methods: {

    // 各种分类请求
    sueSortData () {
      this.$axios({
        method: "get",
        url: "/joys-rest/joys-master-data/appletCategories",
        headers: {
          "AUTH-TOKEN": localStorage.getItem("AUTH-TOKEN")
        },
        params: {
          typeTags: ["MAPP"]
        }
      })
        .then(res => {
          this.sueSortDataInfo = res.data;
          console.log(this.sueSortDataInfo, "shuju");
        })
        .catch(error => {
          console.log(error);
        });
    },
    // 推荐请求
    sueRecommendData () {
      this.$axios({
        method: "get",
        url: "/joys-rest/joys-master-data/applets",
        headers: {
          "AUTH-TOKEN": localStorage.getItem("AUTH-TOKEN")
        },
        params: {
          tag: "SUGGESTION",
          typeTags: ["MAPP"]
        }
      })
        .then(res => {
          this.sueRecommendDataInfo = res.data;
          console.log(this.sueRecommendDataInfo, "fff");
        })
        .catch(error => {
          console.log(error);
        });
    },
    sueRecommendDataInfoImg (id) {
      if (!id) {
        return require("@/assets/img/defaultImg.png");
      } else {
        return (
          this.$baseUrl +
          "/joys-rest/joys-file/file/browse/one2one/" +
          id +
          "?AUTH-TOKEN=" +
          localStorage.getItem("AUTH-TOKEN")
        );
      }
    },
    sueSearch () {
      this.$router.push({
        path: "/sue/sueSearch"
      });
    },
    appItem (val) {
      this.$router.push({
        path: val
        // path: "/iframe",
        // query: {
        //   site: val
        // }
      });
    }
    // path: "/customerManagement"
    // path: "/quoteCalculate"
  },
  created () {
  },
  mounted () {

    this.sueRecommendData();
    this.sueSortData();
  },

};
</script>

<style scoped lang="less">
.sue_img {
  position: fixed;
  z-index: 200;
  top: 0rem;
  right: 0rem;
  height: 0.44rem;
  line-height: 0.44rem;
  padding-right: 0.2rem;
  padding-left: 0.1rem;

  // height: 0.2rem;
  img {
    width: 0.2rem;
  }
}
.scroll {
  .sue_box {
    position: fixed;
    top: 0.44rem;
    bottom: 0.58rem;
    width: 100%;
    background-color: #fbf9fe;
    .sue_title {
      width: 100%;
      height: 0.44rem;
      text-align: center;
      line-height: 0.44rem;
      background: #ffffff;
      box-shadow: inset 0 -1px 0 0 rgba(207, 207, 207, 0.2);
      position: relative;
      p {
        float: left;
        width: 100%;
        font-family: Semibold;
        font-size: 0.17rem;
        color: #3e3e3e;
        letter-spacing: -0.41px;
        text-align: center;
        height: 0.44rem;
        line-height: 0.44rem;
      }
      .sue_title_serach {
        position: absolute;
        right: 0.1rem;
        top: 0;
        margin-left: 0.3rem;
        width: 0.44rem;
        height: 0.44rem;
        img {
          width: 0.2rem;
        }
      }
    }
    .sue_center_box {
      .sue_center_sue {
        overflow: hidden;
        height: 100%;
        .sue_center_sue_info {
          float: left;
          width: 25%;
          text-align: center;
          height: 0.67rem;
          img {
            width: 0.25rem;
            height: 0.25rem;
            display: block;
            margin: auto;
          }
          em {
            font-family: Regular;
            font-size: 0.13rem;
            color: #191919;
            letter-spacing: -0.4px;
            line-height: 0.13rem;
            margin-top: 0.1rem;
            display: block;
          }
        }
      }
    }
    .sue_center_box .sue_center_box_child {
      width: 100%;
      background: #ffffff;
      padding-bottom: auto;
      box-shadow: inset 0 -1px 0 0 rgba(207, 207, 207, 0.2);
      margin-bottom: 0.1rem;
    }
    .sue_center_box div h3 {
      font-family: Mediums;
      font-size: 0.18rem;
      color: #2e2e2e;
      letter-spacing: -0.43px;
      line-height: 0.18rem;
      font-weight: 700;
      padding: 0.2rem 0;
      margin-left: 0.16rem;
    }
  }
}
</style>
